/*-
 * Copyright (c) 2012-2013 Shang-Rong Cai. All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 *
 * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED.  IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 * SUCH DAMAGE.
 *
 * $ MTBLAS: mtblas.h    Rev. 0.0.10    2013-10-08T10:33+08:00 $
 */

#include <stddef.h>
#include <math.h>
#include <complex.h>

#ifndef MTBLAS_H
#define MTBLAS_H

#ifndef SIDX_TYPE
#define SIDX_TYPE
typedef long sidx_t;
#endif

#ifndef STEP_TYPE
#define STEP_TYPE
typedef long step_t;
#endif

/* mtblas_1_dot.c */
extern int mtblas_dotf(size_t thrz, const size_t sz, const float *vx, const step_t incx, const float *vy, const step_t incy, float *buf);

extern int mtblas_dot(size_t thrz, const size_t sz, const double *vx, const step_t incx, const double *vy, const step_t incy, double *buf);

extern int mtblas_dotl(size_t thrz, const size_t sz, const long double *vx, const step_t incx, const long double *vy, const step_t incy, long double *buf);


extern int mtblas_ucdotf(size_t thrz, const size_t sz, const float complex *vx, const step_t incx, const float complex *vy, const step_t incy, float complex *buf);

extern int mtblas_ucdot(size_t thrz, const size_t sz, const double complex *vx, const step_t incx, const double complex *vy, const step_t incy, double complex *buf);

extern int mtblas_ucdotl(size_t thrz, const size_t sz, const long double complex *vx, const step_t incx, const long double complex *vy, const step_t incy, long double complex *buf);


extern int mtblas_cdotf(size_t thrz, const size_t sz, const float complex *vx, const step_t incx, const float complex *vy, const step_t incy, float complex *buf);

extern int mtblas_cdot(size_t thrz, const size_t sz, const double complex *vx, const step_t incx, const double complex *vy, const step_t incy, double complex *buf);

extern int mtblas_cdotl(size_t thrz, const size_t sz, const long double complex *vx, const step_t incx, const long double complex *vy, const step_t incy, long double complex *buf);


/* mtblas_1_nrm.c */
extern int mtblas_nrm2f(size_t thrz, const size_t sz, const float *vx, const step_t incx, float *rbuf);

extern int mtblas_nrm2(size_t thrz, const size_t sz, const double *vx, const step_t incx, double *rbuf);

extern int mtblas_nrm2l(size_t thrz, const size_t sz, const long double *vx, const step_t incx, long double *rbuf);


extern int mtblas_cnrm2f(size_t thrz, const size_t sz, const float complex *vx, const step_t incx, float *rbuf);

extern int mtblas_cnrm2(size_t thrz, const size_t sz, const double complex *vx, const step_t incx, double *rbuf);

extern int mtblas_cnrm2l(size_t thrz, const size_t sz, const long double complex *vx, const step_t incx, long double *rbuf);


extern int mtblas_asumf(size_t thrz, const size_t sz, const float *vx, const step_t incx, float *rbuf);

extern int mtblas_asum(size_t thrz, const size_t sz, const double *vx, const step_t incx, double *rbuf);

extern int mtblas_asuml(size_t thrz, const size_t sz, const long double *vx, const step_t incx, long double *rbuf);


extern int mtblas_casumf(size_t thrz, const size_t sz, const float complex *vx, const step_t incx, float *rbuf);

extern int mtblas_casum(size_t thrz, const size_t sz, const double complex *vx, const step_t incx, double *rbuf);

extern int mtblas_casuml(size_t thrz, const size_t sz, const long double complex *vx, const step_t incx, long double *rbuf);


extern int mtblas_iamaxf(size_t thrz, const size_t sz, const float *vx, const step_t incx, sidx_t *rbuf);

extern int mtblas_iamax(size_t thrz, const size_t sz, const double *vx, const step_t incx, sidx_t *rbuf);

extern int mtblas_iamaxl(size_t thrz, const size_t sz, const long double *vx, const step_t incx, sidx_t *rbuf);


/* mtblas_1_scp.c */
extern int mtblas_swapf(size_t thrz, const size_t sz, float *vx, const step_t incx, float *vy, const step_t incy);

extern int mtblas_swap(size_t thrz, const size_t sz, double *vx, const step_t incx, double *vy, const step_t incy);

extern int mtblas_swapl(size_t thrz, const size_t sz, long double *vx, const step_t incx, long double *vy, const step_t incy);


extern int mtblas_cswapf(size_t thrz, const size_t sz, float complex *vx, const step_t incx, float complex *vy, const step_t incy);

extern int mtblas_cswap(size_t thrz, const size_t sz, double complex *vx, const step_t incx, double complex *vy, const step_t incy);

extern int mtblas_cswapl(size_t thrz, const size_t sz, long double complex *vx, const step_t incx, long double complex *vy, const step_t incy);


extern int mtblas_copyf(size_t thrz, const size_t sz, const float *vx, const step_t incx, float *vy, const step_t incy);

extern int mtblas_copy(size_t thrz, const size_t sz, const double *vx, const step_t incx, double *vy, const step_t incy);

extern int mtblas_copyl(size_t thrz, const size_t sz, const long double *vx, const step_t incx, long double *vy, const step_t incy);


extern int mtblas_ccopyf(size_t thrz, const size_t sz, const float complex *vx, const step_t incx, float complex *vy, const step_t incy);

extern int mtblas_ccopy(size_t thrz, const size_t sz, const double complex *vx, const step_t incx, double complex *vy, const step_t incy);

extern int mtblas_ccopyl(size_t thrz, const size_t sz, const long double complex *vx, const step_t incx, long double complex *vy, const step_t incy);


extern int mtblas_axpyf(size_t thrz, const size_t sz, const float alpha, const float *vx, const step_t incx, float *vy, const step_t incy);

extern int mtblas_axpy(size_t thrz, const size_t sz, const double alpha, const double *vx, const step_t incx, double *vy, const step_t incy);

extern int mtblas_axpyl(size_t thrz, const size_t sz, const long double alpha, const long double *vx, const step_t incx, long double *vy, const step_t incy);


extern int mtblas_caxpyf(size_t thrz, const size_t sz, const float complex alpha, const float complex *vx, const step_t incx, float complex *vy, const step_t incy);

extern int mtblas_caxpy(size_t thrz, const size_t sz, const double complex alpha, const double complex *vx, const step_t incx, double complex *vy, const step_t incy);

extern int mtblas_caxpyl(size_t thrz, const size_t sz, const long double complex alpha, const long double complex *vx, const step_t incx, long double complex *vy, const step_t incy);


extern int mtblas_scalf(size_t thrz, const size_t sz, const float alpha, float *vx, const step_t incx);

extern int mtblas_scal(size_t thrz, const size_t sz, const double alpha, double *vx, const step_t incx);

extern int mtblas_scall(size_t thrz, const size_t sz, const long double alpha, long double *vx, const step_t incx);


extern int mtblas_cscalf(size_t thrz, const size_t sz, const float complex alpha, float complex *vx, const step_t incx);

extern int mtblas_cscal(size_t thrz, const size_t sz, const double complex alpha, double complex *vx, const step_t incx);

extern int mtblas_cscall(size_t thrz, const size_t sz, const long double complex alpha, long double complex *vx, const step_t incx);


extern int mtblas_fcscalf(size_t thrz, const size_t sz, const float alpha, float complex *vx, const step_t incx);

extern int mtblas_fcscal(size_t thrz, const size_t sz, const double alpha, double complex *vx, const step_t incx);

extern int mtblas_fcscall(size_t thrz, const size_t sz, const long double alpha, long double complex *vx, const step_t incx);


#ifndef BLAS_FLAGS
#define BLAS_FLAGS
#define MTBLAS_ROW_MAJOR   101
#define MTBLAS_COL_MAJOR   102

#define MTBLAS_TRANS_NONE  111
#define MTBLAS_TRANS       112
#define MTBLAS_TRANS_CONJ  113

#define MTBLAS_UPLO_UPPER  121
#define MTBLAS_UPLO_LOWER  122

#define MTBLAS_DIAG_NONE   131
#define MTBLAS_DIAG_UNIT   132

#define MTBLAS_SIDE_LEFT   141
#define MTBLAS_SIDE_RIGHT  142
#endif

extern int mtblas_gemvf(size_t thrz, const int rdr, const int trn, const size_t rz, const size_t cz, const float alpha, const float *ma, const size_t lda, const float *vx, const step_t incx, const float beta, float *vy, const step_t incy);

extern int mtblas_gemv(size_t thrz, const int rdr, const int trn, const size_t rz, const size_t cz, const double alpha, const double *ma, const size_t lda, const double *vx, const step_t incx, const double beta, double *vy, const step_t incy);

extern int mtblas_gemvl(size_t thrz, const int rdr, const int trn, const size_t rz, const size_t cz, const long double alpha, const long double *ma, const size_t lda, const long double *vx, const step_t incx, const long double beta, long double *vy, const step_t incy);


extern int mtblas_cgemvf(size_t thrz, const int rdr, const int trn, const size_t rz, const size_t cz, const float complex alpha, const float complex *ma, const size_t lda, const float complex *vx, const step_t incx, const float complex beta, float complex *vy, const step_t incy);

extern int mtblas_cgemv(size_t thrz, const int rdr, const int trn, const size_t rz, const size_t cz, const double complex alpha, const double complex *ma, const size_t lda, const double complex *vx, const step_t incx, const double complex beta, double complex *vy, const step_t incy);

extern int mtblas_cgemvl(size_t thrz, const int rdr, const int trn, const size_t rz, const size_t cz, const long double complex alpha, const long double complex *ma, const size_t lda, const long double complex *vx, const step_t incx, const long double complex beta, long double complex *vy, const step_t incy);

#endif
